// ----------------------------------
// RSDK Project: Sonic 1/Sonic 2
// Script Description: Invincibility Object
// Script Author: Christian Whitehead/Simon Thomley
// Unpacked by Rubberduckycooly's script unpacker
// ----------------------------------

//-------Aliases-------//
private alias 31 : TYPE_INVINCIBILITY


// Static Values

// Tables

event ObjectMain
	if object.state == 0
		object.drawOrder = 7
		object.value0++
		if object.value0 > 3
			object.value0 = 0				
			CreateTempObject(TypeName[Invincibility], 0, object[-playerCount].xpos, object[-playerCount].ypos)
			object[tempObjectPos].state = 1
			object[tempObjectPos].inkEffect = INK_ALPHA
			object[tempObjectPos].alpha = 256
			object[tempObjectPos].drawOrder = object[-playerCount].value18
		end if
		object.frame = ringFrame
		object.frame &= 3
	else
		object.frame = ringFrame
		object.frame &= 3
		object.alpha -= 8
		if object.alpha == 120
			object.type = TypeName[Blank Object]
		end if
	end if
end event


event ObjectDraw
	CheckEqual(object[0].state, PlayerObject_HandleMonikaTeleport)
	temp7 = checkResult
	CheckLower(object[0].value1, 20)
	temp7 &= checkResult
	CheckGreater(object[0].value1, 1)
	temp7 &= checkResult
	if temp7 == 0	
		switch object.state
		case 0
			if object.value0 == 0
				DrawSpriteXY(object.frame, object[-playerCount].xpos, object[-playerCount].ypos)
			end if
			break
		case 1
			object.alpha += 8
			DrawSpriteFX(object.frame, FX_INK, object.xpos, object.ypos)
			object.alpha -= 8
			break
		end switch
	end if	
end event


event ObjectStartup
	LoadSpriteSheet("Global/Items.gif")
	SpriteFrame(-24, -24, 48, 48, 207, 1)
	SpriteFrame(-24, -24, 48, 48, 207, 50)
	SpriteFrame(-24, -24, 48, 48, 207, 99)
	SpriteFrame(-24, -24, 48, 48, 207, 148)
end event

event RSDKDraw
	DrawSprite(0)
end event

event RSDKLoad
	LoadSpriteSheet("Global/Display.gif")
	SpriteFrame(-16, -16, 32, 32, 1, 143)
end event
